home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / O Boy / Source / OBoy_hi.cp < prev    next >
Text File  |  1997-09-24  |  21KB  |  853 lines

  1. /*
  2.     OBoyHI.h
  3.     © Bob Boylan 1996
  4.  
  5.     Revision History
  6.     MacHack 1996        Initial creation
  7.     MH, Fri Morning        pumped up the volume 
  8. */
  9. #include "OBoy_hi.h"
  10. #include "O Boy.h"
  11. #include "Helpers_ut.h"
  12. #include "ComputerAEObj_pd.h"
  13. #include "ComputerAETE_da.h"
  14. #include "ProgressProc_hi.h"
  15. #include "debug.h"
  16.  
  17.  
  18. // file locals
  19. static RGBColor        theCoolGray       = {0x4000, 0x4000, 0x4000};
  20. static RGBColor        theHotGray        = {0x0800, 0x0800, 0x0800};
  21. static RGBColor        theBlack          = {0xFFFF, 0xFFFF, 0xFFFF};
  22. const    Int_16    kButtonWidth = 8;
  23. const    Int_16    kButtonHeight = 8;
  24.  
  25. // class statics
  26. Boolean        OBoy_hi::_CancelWasIssued;
  27. RGBColor    OBoy_hi::_BackGroundGray = {0xE605, 0xE605, 0xE605};
  28.  
  29. //    -----------------------------------------------------------------
  30. //    ctor
  31. //
  32. OBoy_hi::OBoy_hi()
  33.     : _UpNavButton( nil ),
  34.       _DownNavButton( nil ),
  35.       _LeftNavButton( nil ),
  36.       _RightNavButton( nil ),
  37.       _MaxItemsToShow( 10 )
  38. {
  39.     // show the window
  40.         _WindowP = GetNewDialog( 128, nil, (WindowPtr)-1L );
  41.         SetWRefCon(_WindowP, (Int_32) this);
  42.     // init the list
  43.         {
  44.             Int_16    theItemType;
  45.             Handle    theItemHandle;
  46.             Rect    theItemRect;
  47.             Rect    theListBounds = {0,0,0,0};
  48.             Point    theCellSize = {0,0};
  49.             
  50.         
  51.             GetDialogItem((DialogPtr)_WindowP, 1, &theItemType, &theItemHandle, &theItemRect);
  52.             theItemRect.right -= 16;
  53.             
  54.             
  55.             _ListH = LNew(    &theItemRect, &theListBounds, 
  56.                             theCellSize, 0, _WindowP, 
  57.                             true, false, false, true);
  58.             (*_ListH)->selFlags |= lOnlyOne;
  59.             LAddColumn( 1, 0, _ListH );
  60.         }
  61.         
  62.     // init the nav buttons
  63.     UpdateNavRegions();
  64.  
  65.     // progress setup
  66.         _TimeOfLastProgressUpdate = TickCount();
  67.         _Progress = 0;
  68.         _UpdateInProgress = false;
  69.         
  70.         _CancelWasIssued = false;
  71.  
  72. }
  73. //    -----------------------------------------------------------------
  74. //    dtor
  75. //
  76. OBoy_hi::~OBoy_hi()
  77. {
  78.     LDispose( _ListH );
  79.     DisposeWindow( _WindowP );
  80.     
  81.     DisposeRgn(_UpNavButton);
  82.     DisposeRgn(_DownNavButton);
  83.     DisposeRgn(_LeftNavButton);
  84.     DisposeRgn(_RightNavButton);
  85.  
  86. }
  87. //    -----------------------------------------------------------------
  88. //    DrawHierNavButton
  89. //
  90. void 
  91. OBoy_hi::DrawHierNavButton( OBoy_hi::EHButton inButtonToDraw , Boolean inHighlight )
  92. {
  93. const kRoundness = 4;
  94.     // get the bounds
  95.         Rect    theWholeRect;
  96.         {
  97.             Handle    theItemH;
  98.             Int_16    theItemType;
  99.             GetDialogItem(_WindowP, 2, &theItemType, &theItemH, &theWholeRect);
  100.         }
  101.         Int_16            theRectWidth = theWholeRect.right-theWholeRect.left;
  102.         Int_16            theRectHeight = theWholeRect.bottom-theWholeRect.top;
  103.         Point            theCenter;
  104.         Rect            theRect;
  105.  
  106.     StPort    thePort( _WindowP );
  107.     StPen    thePen;
  108.     //    setup the foregr/backgr color
  109.         if( inHighlight == true )
  110.         {
  111.             RGBForeColor( &theHotGray );
  112.             RGBBackColor( &theHotGray );
  113.         }
  114.         else
  115.         {
  116.             RGBForeColor( &theCoolGray );
  117.             RGBBackColor( &theCoolGray );
  118.         }
  119.         
  120.     // calc center
  121.         theCenter.h = theWholeRect.left + (theRectWidth)/2;
  122.         theCenter.v = theWholeRect.top  + (theRectHeight)/2;
  123.     // up button
  124.         if( inButtonToDraw & UpHButton )
  125.         {
  126.             SetRect(&theRect, theCenter.h-kButtonWidth, theWholeRect.top,
  127.                               theCenter.h+kButtonWidth, theCenter.v);
  128.             if( inHighlight ) theRect.bottom -= kButtonWidth;
  129.             PaintRoundRect( &theRect,kRoundness,kRoundness );
  130.         }
  131.     // down button
  132.         if( inButtonToDraw & DownHButton )
  133.         {
  134.  
  135.             SetRect(&theRect, theCenter.h-kButtonWidth, theCenter.v,
  136.                               theCenter.h+kButtonWidth, theWholeRect.bottom);
  137.             if( inHighlight ) theRect.top += kButtonWidth;
  138.             PaintRoundRect( &theRect,kRoundness,kRoundness );
  139.         }
  140.     // left button
  141.         if( inButtonToDraw & LeftHButton )
  142.         {
  143.             SetRect(&theRect, theWholeRect.left,theCenter.v-kButtonHeight,
  144.                               theCenter.h, theCenter.v+kButtonHeight );
  145.             if( inHighlight ) theRect.right -= kButtonWidth;
  146.             PaintRoundRect( &theRect,kRoundness,kRoundness );
  147.         }
  148.     // right button
  149.         if( inButtonToDraw & RightHButton )
  150.         {
  151.             SetRect(&theRect, theCenter.h, theCenter.v-kButtonHeight,
  152.                               theWholeRect.right,theCenter.v+kButtonHeight );
  153.             if( inHighlight ) theRect.left += kButtonWidth;
  154.             PaintRoundRect( &theRect,kRoundness,kRoundness );
  155.         }
  156.  
  157.     // the middle
  158.         DrawO( 0 );            
  159.         
  160. }
  161.  
  162. //    -----------------------------------------------------------------
  163. //    UpdateProgress
  164. //
  165. void
  166. OBoy_hi::UpdateProgress()
  167. {
  168.     // throttle the updates
  169.     if( TickCount() > (_TimeOfLastProgressUpdate + 15L) )
  170.     {
  171.         _TimeOfLastProgressUpdate = TickCount();
  172.         _Progress = (_Progress + 1) & 1;
  173.         DrawO( _Progress + 1 );
  174.     }
  175. }
  176. //    -----------------------------------------------------------------
  177. //    DrawO
  178. //
  179. void
  180. OBoy_hi::DrawO( Int_32 inStage )
  181. {
  182.     StPort    thePort( _WindowP );
  183.     StPen    thePen;
  184.  
  185.     if( inStage == 0 )
  186.     {
  187.         RGBForeColor( &_BackGroundGray );
  188.         RGBBackColor( &_BackGroundGray );
  189.     }
  190.     else if( inStage == 1 )
  191.     {
  192.         RGBForeColor( &theCoolGray );
  193.         RGBBackColor( &theCoolGray );
  194.     }
  195.     else
  196.     {
  197.         RGBForeColor( &theHotGray );
  198.         RGBBackColor( &theHotGray );
  199.     }
  200.  
  201.     Rect    theWholeRect;
  202.     {
  203.         Handle    theItemH;
  204.         Int_16    theItemType;
  205.         GetDialogItem(_WindowP, 2, &theItemType, &theItemH, &theWholeRect);
  206.     }
  207.     
  208.     InsetRect( &theWholeRect, (theWholeRect.right-theWholeRect.left)/2 - kButtonWidth + 1,
  209.                               (theWholeRect.right-theWholeRect.left)/2 - kButtonWidth + 1 );
  210.     PaintOval( &theWholeRect );                                    
  211.             
  212. }
  213. //    -----------------------------------------------------------------
  214. //    ReDraw
  215. //
  216. void 
  217. OBoy_hi::ReDraw()
  218. {
  219. Int_16    theItemType;
  220. Handle    theItemH;
  221. Rect    theRect;
  222.  
  223.     // save current state
  224.         StPort    thePort( _WindowP );
  225.         StPen    thePen;
  226.         thePen.Reset();
  227.     // hier navigator
  228.         DrawHierNavButton();
  229.     
  230.     // 'a' button
  231.         GetDialogItem(_WindowP, 3, &theItemType, &theItemH, &theRect);
  232.         RGBForeColor( &theCoolGray );
  233.         RGBBackColor( &theCoolGray );
  234.         PaintOval( &theRect );
  235.     // 'b' button
  236.         GetDialogItem(_WindowP, 4, &theItemType, &theItemH, &theRect);
  237.         PaintOval( &theRect );
  238.  
  239.     // the list
  240.         thePen.Reset();
  241.         
  242.         GetDialogItem(_WindowP, 1, &theItemType, &theItemH, &theRect);
  243.         EraseRect( &theRect );
  244.         
  245.         LUpdate( _WindowP->visRgn, _ListH );
  246.         GetDialogItem(_WindowP, 1, &theItemType, &theItemH, &theRect);
  247.         InsetRect( &theRect, -1, -1 );
  248.         FrameRect( &theRect );
  249.         
  250.         if( _Obj.Isnil() == true )
  251.         {
  252.             AEObj_pd *    theObjP = new ComputerAEObj_pd;
  253.             _Obj = Clone_ut<AEObj_pd> (theObjP);
  254.             UpdateObjectData();
  255.         }
  256.         else
  257.         {
  258.             UpdateName();
  259.         }
  260.         
  261.     // the grow job
  262.         {
  263.         RgnHandle    theRgn = NewRgn();
  264.             GetClip ( theRgn );
  265.                     Rect theRect;   
  266.                     SetRect( &theRect,_WindowP->portRect.right-15,
  267.                                      _WindowP->portRect.bottom-15,
  268.                                      _WindowP->portRect.right,
  269.                                      _WindowP->portRect.bottom );
  270.                     ClipRect( &theRect );
  271.                     DrawGrowIcon( _WindowP );
  272.                     SetClip( theRgn );
  273.             DisposeRgn( theRgn );
  274.         }
  275.         
  276. }
  277. //    -----------------------------------------------------------------
  278. //    UpdateName ... the text box indicating the path to an object
  279. //
  280. void
  281. OBoy_hi::UpdateName()
  282. {
  283. Int_16    theItemType;
  284. Handle    theItemH;
  285. Rect    theRect;
  286.  
  287. string    theName = (*_Obj).GetFullName();
  288.  
  289. StPort    thePort( _WindowP );
  290.  
  291.     GetDialogItem(_WindowP, 5, &theItemType, &theItemH, &theRect);
  292.     StPen    thePen;
  293.     thePen.Reset();
  294.     RGBBackColor( &_BackGroundGray );
  295.  
  296.     TextFont( applFont );
  297.     TextSize( 9 );
  298.         TETextBox(theName.c_str(), theName.length(), &theRect, teFlushLeft);
  299.     TextFont( systemFont );
  300.     TextSize( 12 );
  301.  
  302. }
  303. //    -----------------------------------------------------------------
  304. //    UpdateObjectData
  305. //
  306. void
  307. OBoy_hi::UpdateObjectData()
  308. {
  309. ProgressProc_hi    theProgress( this );
  310.     // start fresh
  311.         {
  312.             vector< Clone_ut<AEObj_pd> >    theNullObjSet;
  313.             _SubModels = theNullObjSet;
  314.         }
  315.         {
  316.             vector< Clone_ut<PropertyValue_pd> >    theNullPropSet;
  317.             _PropertyValues = theNullPropSet;
  318.         }
  319.  
  320.     
  321.     // update the name, then the object data, then the name ( could have changed)
  322.     _UpdateInProgress = true;
  323.         UpdateName();
  324.         (*_Obj).Update( theProgress, _MaxItemsToShow );
  325.         UpdateName();
  326.     _UpdateInProgress = false;
  327.  
  328.     DrawO( 0 );
  329.     
  330.     _CancelWasIssued = false;
  331.  
  332. }
  333. //    -----------------------------------------------------------------
  334. //    NewSubModel
  335. //
  336. void
  337. OBoy_hi::NewSubModel( Clone_ut< AEObj_pd > inAEobj )
  338. {
  339.     _SubModels.push_back( inAEobj );
  340.     UpdateProgress();
  341. }
  342. //    -----------------------------------------------------------------
  343. //    NewPropertyValue
  344. //
  345. void
  346. OBoy_hi::NewPropertyValue( Clone_ut< PropertyValue_pd > inPropertyValue )
  347. {
  348.     _PropertyValues.push_back( inPropertyValue );
  349.     UpdateProgress();
  350. }
  351.  
  352.  
  353. //    -----------------------------------------------------------------
  354. //    HandleNavButton
  355. //
  356. void
  357. OBoy_hi::HandleNavButton(EventRecord * inEventP, Point inLocalWhere)
  358. {
  359. EHButton    theButton = FindHButton( inLocalWhere );
  360. EHButton    thePointIn, theLastPointIn;
  361. Point        thePoint, theLastPoint;
  362.  
  363.     // see what the user is going to do
  364.         thePoint = inLocalWhere;
  365.         theLastPoint.h = 0; theLastPoint.v = 0;
  366.         while( StillDown() )
  367.         {
  368.             GetMouse( &thePoint );
  369.             if( (thePoint.h != theLastPoint.h) || (thePoint.v != theLastPoint.v ) )
  370.             {
  371.                 thePointIn = FindHButton( thePoint  );
  372.                 theLastPointIn = FindHButton( theLastPoint );
  373.                 if( thePointIn != theLastPointIn )
  374.                 {
  375.                     DrawHierNavButton( theButton, (thePointIn == theButton) );
  376.                 }
  377.                 theLastPoint = thePoint;
  378.             }
  379.         }
  380.     
  381.     // act, restore image
  382.         if( thePointIn == theButton )
  383.         {
  384.             NavigateHier( theButton, inEventP  );
  385.             DrawHierNavButton( theButton);
  386.         }
  387.  
  388. }
  389.  
  390. //    -----------------------------------------------------------------
  391. //    FindHButton
  392. //
  393. OBoy_hi::EHButton
  394. OBoy_hi::FindHButton( Point inLocation )
  395. {
  396. EHButton    theRetVal;
  397.     if( PtInRgn( inLocation,_UpNavButton ) )
  398.     {
  399.         theRetVal = UpHButton;
  400.     }
  401.     else if ( PtInRgn( inLocation, _DownNavButton ) )
  402.     {
  403.         theRetVal = DownHButton ;
  404.     }
  405.     else if ( PtInRgn( inLocation, _LeftNavButton ) )
  406.     {
  407.         theRetVal = LeftHButton ;
  408.     }
  409.     else if ( PtInRgn( inLocation, _RightNavButton ) )
  410.     {
  411.         theRetVal = RightHButton ;
  412.     }
  413.     else
  414.     {
  415.         theRetVal = NoHButton ;
  416.     }
  417.  
  418.     return theRetVal;
  419. }
  420.  
  421. //    -----------------------------------------------------------------
  422. //    NavigateHier
  423. //
  424. void
  425. OBoy_hi::NavigateHier( OBoy_hi::EHButton inDirection, EventRecord *inEventP )
  426. {
  427. Cell theCell = LLastClick( _ListH );
  428. Boolean    theCommandKeyDown = (inEventP->modifiers & cmdKey) != 0 ;
  429. Boolean    theOptionKeyDown = (inEventP->modifiers & optionKey) != 0 ;
  430.  
  431.     // which way was the request?
  432.             switch( inDirection )
  433.             {
  434.                 case     UpHButton:
  435.                 {
  436.                     if( (*_Obj).GetKindID() != cComputer )
  437.                     {
  438.                         _Obj =  (*_Obj).GetParent();
  439.                         if( theCommandKeyDown == true )
  440.                         {    // all the way up
  441.                             while( (*_Obj).GetKindID() != cComputer )
  442.                             {
  443.                                 _Obj =  (*_Obj).GetParent();
  444.                             }
  445.                         }
  446.                     }
  447.                 }
  448.                 break;
  449.                 
  450.                 case    DownHButton:
  451.                 {
  452.                 // see what the user has selected - could be a property
  453.                     if( theCell.v >= _PropertyValues.size() )
  454.                     {
  455.                         Int_32    theIndex = theCell.v - _PropertyValues.size();
  456.                         if( theIndex < _SubModels.size() )
  457.                         {
  458.                             _Obj = _SubModels[ theIndex ];
  459.                         }
  460.                         else
  461.                         {
  462.                             if( _SubModels.size() > 0 )
  463.                             {
  464.                                 _Obj = _SubModels[ 0 ];
  465.                             }
  466.                         }
  467.                     }
  468.                 }
  469.                 break;
  470.                 
  471.                 case    LeftHButton:
  472.                 {
  473.                     if( (*_Obj).GetKindID() != cComputer )
  474.                     {
  475.                         Int_32    theLeftLimit;
  476.                         if( (*_Obj).GetKindID() == cFinderProcess )
  477.                         {
  478.                             theLeftLimit = 0;
  479.                         }
  480.                         else
  481.                         {
  482.                             theLeftLimit = 1;
  483.                         }
  484.                         if ( (*_Obj).GetPosition() > theLeftLimit )
  485.                         {
  486.                             Int_32    theDelta = -1;
  487.                             if( theCommandKeyDown == true )
  488.                             {    // go all the way to the left
  489.                                 theDelta = -((*_Obj).GetPosition() - theLeftLimit);
  490.                             }
  491.                             else if( theOptionKeyDown == true )
  492.                             {    // go in steps of _MaxItemsToShow, start at a value divisible by _MaxItemsToShow
  493.                             Int_32 thePositionWeWant = ((*_Obj).GetPosition()/_MaxItemsToShow)*_MaxItemsToShow;
  494.                                 if( thePositionWeWant == (*_Obj).GetPosition() ) 
  495.                                 {
  496.                                     thePositionWeWant = thePositionWeWant - _MaxItemsToShow;
  497.                                 }
  498.                                 if( thePositionWeWant < _MaxItemsToShow )
  499.                                 {
  500.                                     theDelta = -((*_Obj).GetPosition() - theLeftLimit);
  501.                                 }
  502.                                 else
  503.                                 {
  504.                                     theDelta = -((*_Obj).GetPosition() - thePositionWeWant);
  505.                                 }
  506.                             }
  507.                             _Obj = (*_Obj).GetSibling( theDelta );
  508.                         }
  509.                     }
  510.                 }
  511.                 break;
  512.                 
  513.                 case    RightHButton:
  514.                 {
  515.                     if( (*_Obj).GetKindID() != cComputer )
  516.                     {
  517.                         Int_32    theDelta = 1;
  518.                         if( theCommandKeyDown == true )
  519.                         {    // go all the way to the right
  520.                             Clone_ut<AEObj_pd> theParent = (*_Obj).GetParent();
  521.                             Int_32 theNSubs = (*theParent).GetSubModelCount( (*_Obj).GetKindID() );
  522.                             if( theNSubs > (*_Obj).GetPosition() )
  523.                             {
  524.                                 theDelta = theNSubs - (*_Obj).GetPosition();
  525.                             }
  526.                             else
  527.                             {
  528.                                 theDelta = (*_Obj).GetPosition() - theNSubs; 
  529.                             }
  530.         
  531.                         }
  532.                         else if( theOptionKeyDown == true )
  533.                         {    // go in steps of _MaxItemsToShow
  534.                             Int_32 thePositionWeWant = ((*_Obj).GetPosition()/_MaxItemsToShow)*_MaxItemsToShow + _MaxItemsToShow;
  535.                             theDelta = thePositionWeWant - (*_Obj).GetPosition();
  536.                         }
  537.                         if( theDelta > 0 )
  538.                         {
  539.                             _Obj = (*_Obj).GetSibling( theDelta );
  540.                         }
  541.                     }
  542.                 }
  543.                 break;
  544.             }
  545.             
  546.             
  547.             // all done deciding who gets it ... now give it to them
  548.             UpdateObjectData();
  549. }
  550. //    -----------------------------------------------------------------
  551. //    HandleClick
  552. //
  553. void
  554. OBoy_hi::HandleClick(EventRecord * inEventP)
  555. {
  556. Point    thelocalWhere;
  557. StPort    thePort( _WindowP );
  558.  
  559.         thelocalWhere = inEventP->where;
  560.         GlobalToLocal(&thelocalWhere);
  561.         ControlHandle    theControlH;
  562.         Int_16 thePartCode = FindDialogItem(_WindowP, thelocalWhere) + 1;
  563.         switch( thePartCode )
  564.         {
  565.             case 1:    // the list
  566.                 {
  567.                     StPen    thePen;
  568.                     thePen.Reset();
  569.  
  570.                     Boolean    theDblClickFlag = LClick( thelocalWhere, inEventP->modifiers, _ListH );
  571.                     if( (_UpdateInProgress == false ) && (theDblClickFlag == true) )
  572.                     {
  573.                         NavigateHier( DownHButton, inEventP  );
  574.                     }
  575.                 }
  576.                 break;
  577.             case 2:    // the nav button
  578.                 if( _UpdateInProgress == false )
  579.                 {
  580.                     HandleNavButton( inEventP, thelocalWhere );
  581.                 }
  582.                 break;
  583.             case 3:    // the 'a' button 
  584.                 if( TrackButtonHit( thePartCode ) == true )
  585.                 {
  586.                     if( _UpdateInProgress == false )
  587.                     {
  588.                         if ( ((inEventP->modifiers & cmdKey) !=0)  && (_MaxItemsToShow == 10) )
  589.                         {
  590.                             _MaxItemsToShow = 11; // pump up the volume - this is MacHack 11 (Spinal Hack)
  591.                         }
  592.                         UpdateObjectData();
  593.                     }
  594.                 }
  595.                 break;
  596.             case 4:    // the 'b' button 
  597.                 if( TrackButtonHit( thePartCode ) == true )
  598.                 {
  599.                     ShowAbout();
  600.                 }
  601.                 break;
  602.             default:
  603.                 break;
  604.         }
  605. }
  606.  
  607. //    -----------------------------------------------------------------
  608. //    HandleKeyDownEvent
  609. //
  610. void
  611. OBoy_hi::HandleKeyDownEvent(EventRecord &theEvent)
  612. {
  613. char    theKey;
  614. char    theVirtualKey;
  615.     
  616.     theKey=theEvent.message & charCodeMask;
  617.     theVirtualKey = (theEvent.message & keyCodeMask) >> 8;
  618.  
  619.     if ( (theEvent.modifiers & cmdKey) !=0 )
  620.     {
  621.     EHButton theNavButton = NoHButton;
  622.         switch( theKey )
  623.         {
  624.             case '.':
  625.                 _CancelWasIssued = true;    // ahhh ... cancel
  626.                 break;
  627.             default:
  628.                 break;
  629.         }
  630.     }
  631.         
  632. }
  633.  
  634. //    -----------------------------------------------------------------
  635. //    TrackButtonHit
  636. //
  637. Boolean
  638. OBoy_hi::TrackButtonHit( Int_16 inButtonItem )
  639. {
  640. Int_16    theItemType;
  641. Handle    theItemH;
  642. Rect    theRect;
  643.     
  644.     StPort    thePort( _WindowP );
  645.     StPen    theBigPen;
  646.     //    get the rect involved
  647.         GetDialogItem(_WindowP, inButtonItem, &theItemType, &theItemH, &theRect);
  648.         InsetRect( &theRect,1,1 );
  649.  
  650.  
  651.         Boolean    thePointIn;
  652.         {
  653.             StPen thePen;    // save the current
  654.             
  655.         // hang out till the user mouses up                
  656.             Point    thePoint, theLastPoint;
  657.             Boolean    theLastPointIn;
  658.             theLastPoint.h = 0; theLastPoint.v = 0;
  659.             while( StillDown() )
  660.             {
  661.                 GetMouse( &thePoint );
  662.                 if( (thePoint.h != theLastPoint.h) || (thePoint.v != theLastPoint.v ) )
  663.                 {
  664.                     thePointIn = PtInRect( thePoint, &theRect );
  665.                     theLastPointIn = PtInRect( theLastPoint, &theRect );
  666.                     if( thePointIn != theLastPointIn )
  667.                     {
  668.                         if( thePointIn )
  669.                         {
  670.                             RGBForeColor( &theHotGray );
  671.                             RGBBackColor( &theHotGray );
  672.                             PaintOval( &theRect );
  673.                         }
  674.                         else
  675.                         {
  676.                             RGBForeColor( &theCoolGray );
  677.                             RGBBackColor( &theCoolGray );
  678.                             PaintOval( &theRect );
  679.                         }
  680.                     }
  681.                     theLastPoint = thePoint;
  682.                 }
  683.             }
  684.     
  685.         }
  686.     // restore image
  687.         if( thePointIn == true )
  688.         {
  689.             RGBForeColor( &theCoolGray );
  690.             RGBBackColor( &theCoolGray );
  691.             PaintOval( &theRect );
  692.         }
  693.     // and the result
  694.         return thePointIn;
  695. }
  696.  
  697. //    -----------------------------------------------------------------
  698. //    ShowAbout
  699. //
  700. void
  701. OBoy_hi::ShowAbout()
  702. {
  703. StPort    thePort;
  704.  
  705. DialogPtr    theDialogP = GetNewDialog( 129, nil, (WindowPtr)-1L );
  706.  
  707.     SetPort( theDialogP );
  708.         Int_16    theItemType;
  709.         Handle    theItemHandle;
  710.         Rect    theItemRect, theTextItemRect;
  711.             
  712.         // get the popup control        
  713.         GetDialogItem((DialogPtr)theDialogP, 2, &theItemType, &theItemHandle, &theItemRect);
  714.         ControlHandle    thePopupControlH = (ControlHandle) theItemHandle;
  715.         SetControlValue( thePopupControlH, 2 );        // default is what
  716.  
  717.         // get the text item rect
  718.         GetDialogItem((DialogPtr)theDialogP, 3, &theItemType, &theItemHandle, &theTextItemRect);
  719.  
  720.         Int_16    theItemHit = 2;
  721.         while( theItemHit != 1 )
  722.         {
  723.             if( theItemHit == 2 )
  724.             {
  725.                 Int_16    theItemNumber = GetControlValue( thePopupControlH );
  726.                 dassert( theItemNumber > 0 );
  727.                 Handle theTextH  = GetResource( 'TEXT', 999 + theItemNumber );
  728.                     HLock( theTextH );
  729.                         TextFont( monaco );
  730.                         TextSize( 9 );
  731.                             TETextBox( *theTextH, GetHandleSize( theTextH ), &theTextItemRect, teFlushLeft );
  732.                         TextFont( systemFont );
  733.                         TextSize( 12 );
  734.                     HUnlock( theTextH );
  735.                 ReleaseResource( theTextH );
  736.                 
  737.             }            
  738.             
  739.             ModalDialog( nil, &theItemHit );
  740.         }
  741.     DisposeDialog( theDialogP );
  742.     
  743. }
  744.  
  745.  
  746.  
  747. //    -----------------------------------------------------------------
  748. //    AdjustToSize
  749. //
  750. void
  751. OBoy_hi::AdjustToSize( Rect theOldRect, Rect theNewRect )
  752. {
  753. Int_16    theDeltaX = theNewRect.right - theOldRect.right;
  754. Int_16    theDeltaY = theNewRect.bottom - theOldRect.bottom;
  755.  
  756. Int_16    theItemType;
  757. Handle    theItemHandle;
  758. Rect    theItemRect;
  759.             
  760.         StPort    theSavePort( _WindowP );
  761.  
  762.     // adjust the list item
  763.         GetDialogItem((DialogPtr)_WindowP, 1, &theItemType, &theItemHandle, &theItemRect);
  764.         theItemRect.right += theDeltaX;
  765.         theItemRect.bottom += theDeltaY;
  766.         SetDialogItem((DialogPtr)_WindowP, 1, theItemType, theItemHandle, &theItemRect);
  767.         LSize((theItemRect.right - theItemRect.left) - 15,
  768.               (theItemRect.bottom - theItemRect.top), _ListH );
  769.         Point theCellSize = (**_ListH).cellSize;
  770.         theCellSize.h = (theItemRect.right - theItemRect.left) - 15;
  771.         LCellSize ( theCellSize, _ListH);            
  772.  
  773.  
  774.     // adjust the nav button
  775.         GetDialogItem((DialogPtr)_WindowP, 2, &theItemType, &theItemHandle, &theItemRect);
  776.         OffsetRect( &theItemRect, 0, theDeltaY );
  777.         SetDialogItem((DialogPtr)_WindowP, 2, theItemType, theItemHandle, &theItemRect);
  778.         UpdateNavRegions();
  779.  
  780.     // adjust the 'a' button
  781.         GetDialogItem((DialogPtr)_WindowP, 3, &theItemType, &theItemHandle, &theItemRect);
  782.         OffsetRect( &theItemRect, theDeltaX, theDeltaY );
  783.         SetDialogItem((DialogPtr)_WindowP, 3, theItemType, theItemHandle, &theItemRect);
  784.             
  785.     // adjust the 'b' button
  786.         GetDialogItem((DialogPtr)_WindowP, 4, &theItemType, &theItemHandle, &theItemRect);
  787.         OffsetRect( &theItemRect, theDeltaX, theDeltaY );
  788.         SetDialogItem((DialogPtr)_WindowP, 4, theItemType, theItemHandle, &theItemRect);
  789.             
  790.     // adjust the text item
  791.         GetDialogItem((DialogPtr)_WindowP, 5, &theItemType, &theItemHandle, &theItemRect);
  792.         theItemRect.right += theDeltaX;
  793.         theItemRect.top += theDeltaY;
  794.         theItemRect.bottom += theDeltaY;
  795.         SetDialogItem((DialogPtr)_WindowP, 5, theItemType, theItemHandle, &theItemRect);
  796.  
  797.     // update
  798.         InvalRect( &_WindowP->portRect );
  799. }
  800.  
  801. //    -----------------------------------------------------------------
  802. //    UpdateNavRegions
  803. //
  804. void
  805. OBoy_hi::UpdateNavRegions()
  806. {
  807.     if( _UpNavButton != nil )
  808.     {
  809.         DisposeRgn(_UpNavButton);
  810.         DisposeRgn(_DownNavButton);
  811.         DisposeRgn(_LeftNavButton);
  812.         DisposeRgn(_RightNavButton);
  813.  
  814.     }
  815.     _UpNavButton = NewRgn();
  816.     _DownNavButton = NewRgn();
  817.     _LeftNavButton = NewRgn();
  818.     _RightNavButton = NewRgn();
  819.  
  820.     Handle    theItemH;
  821.     Int_16    theItemType;
  822.     Rect    theRect;
  823.     Point    theCenter;
  824.     GetDialogItem(_WindowP, 2, &theItemType, &theItemH, &theRect);
  825.     theCenter.h = theRect.left + (theRect.right-theRect.left)/2;
  826.     theCenter.v = theRect.top  + (theRect.bottom-theRect.top)/2;
  827.     OpenRgn();
  828.         MoveTo( theCenter.h, theCenter.v );
  829.         LineTo( theRect.right, theRect.top );
  830.         LineTo( theRect.left, theRect.top );
  831.         LineTo( theCenter.h, theCenter.v );
  832.     CloseRgn( _UpNavButton );
  833.     OpenRgn();
  834.         MoveTo( theCenter.h, theCenter.v );
  835.         LineTo( theRect.right, theRect.bottom );
  836.         LineTo( theRect.left, theRect.bottom );
  837.         LineTo( theCenter.h, theCenter.v );
  838.     CloseRgn( _DownNavButton );
  839.     OpenRgn();
  840.         MoveTo( theCenter.h, theCenter.v );
  841.         LineTo( theRect.left, theRect.top );
  842.         LineTo( theRect.left, theRect.bottom );
  843.         LineTo( theCenter.h, theCenter.v );
  844.     CloseRgn( _LeftNavButton );
  845.     OpenRgn();
  846.         MoveTo( theCenter.h, theCenter.v );
  847.         LineTo( theRect.right, theRect.top );
  848.         LineTo( theRect.right, theRect.bottom );
  849.         LineTo( theCenter.h, theCenter.v );
  850.     CloseRgn( _RightNavButton );
  851.  
  852. }
  853.